package com.clms.marketings.controller;

import com.clms.common.R;
import com.clms.marketings.pojo.entity.SmsAdvertisePosition;
import com.clms.marketings.pojo.vo.AdvertisePositionVo;
import com.clms.marketings.pojo.vo.AdvertiseTypeVo;
import com.clms.marketings.service.SmsAdvertisePositionService;
import io.swagger.annotations.ApiModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-third
 * @description: 广告位置的控制层
 * @author: 赵露露
 * @create: 2021-07-23 21:22
 **/
@RestController
@RequestMapping("/marketing/position")
public class SmsAdvertisePositionController {
    @Autowired
    private SmsAdvertisePositionService smsAdvertisePositionService;
    //查询所有广告位置
    @GetMapping("selectall")
    public R selectAll(){
        return smsAdvertisePositionService.selectAll();
    }
    //增加广告位置
    @PostMapping("insertposition")
    public R insertPosition(@RequestBody SmsAdvertisePosition smsAdvertisePosition){
        return smsAdvertisePositionService.insertPosition(smsAdvertisePosition);
    }
    //修改广告位置
    @PutMapping("updateposition")
    public R updatePosition(@RequestBody SmsAdvertisePosition smsAdvertisePosition){
        return smsAdvertisePositionService.updatePosition(smsAdvertisePosition);
    }
    //删除广告位置
    @DeleteMapping("deleteposition")
    public R deletePosition(@RequestParam Integer id){
        return smsAdvertisePositionService.deletePosition(id);
    }
    //根据id查广告位置
    @GetMapping("selectbyid/{id}")
    public R selectById(@PathVariable Integer id){
        return smsAdvertisePositionService.selectById(id);
    }
    //分页
    @PostMapping("/selectpage/{currentPage}/{pageSize}")
    public R selectPage(@PathVariable Integer currentPage,
                        @PathVariable Integer pageSize,
                        @RequestBody AdvertisePositionVo advertisePositionVo){
        return smsAdvertisePositionService.selectPage(currentPage,pageSize,advertisePositionVo);
    }
    //唯一性校验
    @PostMapping("/nameunique")
    public R nameUnique(@RequestBody AdvertiseTypeVo advertiseTypeVo){
        return smsAdvertisePositionService.nameUnique(advertiseTypeVo);
    }
}
